;(function($){

$.extend({

SlideEffect: function(json){

var timer = null;
var index = 1;
var index2= 0;
var number = $(json.main).children("li").length-2;
var wid = $(json.main).children().eq(0).width();

$(json.main).css("left",-wid+"px");

function cur(index2){
	$(json.control).children("li").eq(index2).addClass(json.cur).siblings().removeClass(json.cur);
}

$(json.main).children("li").each(function(index,value){

	if(index < number){
		$(json.control).append("<li></li>");
		$(json.control).children("li").eq(0).addClass(json.cur);
	}
});

var number2 = $(json.control).children("li").length;
function play(){
	index++;  
	index2++;  
	if(index > number){
		index = 1;
		$(json.main).css("left",0+"px");
	}
	$(json.main).stop().animate({
		"left": -index*wid+"px"
	},800,"swing");
	if(index2 > number2-1){
		index2 = 0;
	}
	cur(index2);

}


	timer = setInterval(play,3000);


$(json.control).children("li").on("click",function(){
	var num = $(this).index();
	index2 = num;
	index = num+1;
	cur(index2);
	$(json.main).stop().animate({
		"left": -index*wid+"px"
	},800,"swing");
});

$(json.prev).on("click",function(){
	index--;
	index2--;
	if(index < 0){
		index = number-1;
		$(json.main).css("left",-number*wid+"px");
	}
	$(json.main).stop().animate({
		"left": -index*wid+"px"
	},800,"swing");
	if(index2 < 0){
		index2 = number2-1;
	}
		cur(index2);
});

$(json.next).on("click",function(){
	index++;  
	index2++;  
	if(index > number){
		index = 1;
		$(json.main).css("left",0+"px");
	}
	$(json.main).stop().animate({
		"left": -index*wid+"px"
	},800,"swing");
	if(index2 > number2-1){
		index2 = 0;
	}
	cur(index2);
});

$(window).on("blur",function(){
	clearInterval(timer);
});

$(window).on("focus",function(){
	clearInterval(timer);
	timer = setInterval(play,3000);
});

$(json.container).on("mouseenter",function(){

	clearInterval(timer);
});

$(json.container).on("mouseleave",function(){

	timer = setInterval(play,3000);
});


















}
});
})(jQuery);